package sudroid.net2;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import sudroid.FileUtil;

public class PostParameter
  implements Serializable, Comparable<PostParameter>
{
  private static final String GIF = "image/gif";
  private static final String JPEG = "image/jpeg";
  private static final String OCTET = "application/octet-stream";
  private static final String PNG = "image/png";
  private static final long serialVersionUID = 8874362034517485152L;
  private InputStream input = null;
  String name;
  String value;

  public PostParameter(String paramString, double paramDouble)
  {
    this.name = paramString;
    String str = String.valueOf(paramDouble);
    this.value = str;
  }

  public PostParameter(String paramString, int paramInt)
  {
    this.name = paramString;
    String str = String.valueOf(paramInt);
    this.value = str;
  }

  public PostParameter(String paramString, File paramFile)
    throws FileNotFoundException
  {
    this(paramString, localBufferedInputStream);
  }

  public PostParameter(String paramString, InputStream paramInputStream)
  {
    this.name = paramString;
    InputStream localInputStream = FileUtil.makeInputBuffered(paramInputStream);
    this.input = localInputStream;
  }

  public PostParameter(String paramString1, String paramString2)
  {
    this.name = paramString1;
    this.value = paramString2;
  }

  public static boolean containsFile(Collection<PostParameter> paramCollection)
  {
    int i = 0;
    Iterator localIterator = paramCollection.iterator();
    if (!localIterator.hasNext());
    while (true)
    {
      return i;
      if (!((PostParameter)localIterator.next()).isFile())
        break;
      i = 1;
    }
  }

  public static boolean containsFile(PostParameter[] paramArrayOfPostParameter)
  {
    int i = 0;
    int j = 0;
    if (paramArrayOfPostParameter == null)
    {
      k = 0;
      return k;
    }
    int k = paramArrayOfPostParameter.length;
    while (true)
    {
      if (i >= k);
      while (true)
      {
        k = j;
        break;
        if (!paramArrayOfPostParameter[i].isFile())
          break label39;
        j = 1;
      }
      label39: i += 1;
    }
  }

  public static String encodeParameters(List<PostParameter> paramList)
  {
    String str1;
    if (paramList == null)
    {
      str1 = "";
      return str1;
    }
    StringBuilder localStringBuilder1 = new StringBuilder();
    int i = 0;
    int j = paramList.size();
    while (true)
    {
      if (i >= j)
      {
        str1 = localStringBuilder1.toString();
        break;
      }
      PostParameter localPostParameter = (PostParameter)paramList.get(i);
      if (localPostParameter.isFile())
      {
        StringBuilder localStringBuilder2 = new StringBuilder("parameter [");
        String str2 = localPostParameter.name;
        String str3 = str2 + "]should be text";
        throw new IllegalArgumentException(str3);
      }
      if (i != 0)
        StringBuilder localStringBuilder3 = localStringBuilder1.append("&");
      try
      {
        String str4 = URLEncoder.encode(localPostParameter.name, "UTF-8");
        StringBuilder localStringBuilder4 = localStringBuilder1.append(str4).append("=");
        String str5 = URLEncoder.encode(localPostParameter.value, "UTF-8");
        StringBuilder localStringBuilder5 = localStringBuilder4.append(str5);
        label164: i += 1;
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        break label164;
      }
    }
  }

  public static String encodeParameters(PostParameter[] paramArrayOfPostParameter)
  {
    String str1;
    if (paramArrayOfPostParameter == null)
    {
      str1 = "";
      return str1;
    }
    StringBuilder localStringBuilder1 = new StringBuilder();
    int i = 0;
    while (true)
    {
      int j = paramArrayOfPostParameter.length;
      if (i >= j)
      {
        str1 = localStringBuilder1.toString();
        break;
      }
      if (paramArrayOfPostParameter[i].isFile())
      {
        StringBuilder localStringBuilder2 = new StringBuilder("parameter [");
        String str2 = paramArrayOfPostParameter[i].name;
        String str3 = str2 + "]should be text";
        throw new IllegalArgumentException(str3);
      }
      if (i != 0)
        StringBuilder localStringBuilder3 = localStringBuilder1.append("&");
      try
      {
        String str4 = URLEncoder.encode(paramArrayOfPostParameter[i].name, "UTF-8");
        StringBuilder localStringBuilder4 = localStringBuilder1.append(str4).append("=");
        String str5 = URLEncoder.encode(paramArrayOfPostParameter[i].value, "UTF-8");
        StringBuilder localStringBuilder5 = localStringBuilder4.append(str5);
        label152: i += 1;
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        break label152;
      }
    }
  }

  public static String getFileContentType(String paramString)
  {
    String str1 = paramString;
    int i = str1.lastIndexOf(".");
    String str2;
    if (-1 == i)
      str2 = "application/octet-stream";
    while (true)
    {
      return str2;
      int j = str1.lastIndexOf(".") + 1;
      str1 = str1.substring(j).toLowerCase();
      if (str1.length() == 3)
      {
        if ("gif".equals(str1))
        {
          str2 = "image/gif";
          continue;
        }
        if ("png".equals(str1))
        {
          str2 = "image/png";
          continue;
        }
        if ("jpg".equals(str1))
        {
          str2 = "image/jpeg";
          continue;
        }
        str2 = "application/octet-stream";
        continue;
      }
      if (str1.length() == 4)
      {
        if ("jpeg".equals(str1))
        {
          str2 = "image/jpeg";
          continue;
        }
        str2 = "application/octet-stream";
        continue;
      }
      str2 = "application/octet-stream";
    }
  }

  public static PostParameter[] getParameterArray(String paramString, int paramInt)
  {
    String str = String.valueOf(paramInt);
    return getParameterArray(paramString, str);
  }

  public static PostParameter[] getParameterArray(String paramString1, int paramInt1, String paramString2, int paramInt2)
  {
    String str1 = String.valueOf(paramInt1);
    String str2 = String.valueOf(paramInt2);
    return getParameterArray(paramString1, str1, paramString2, str2);
  }

  public static PostParameter[] getParameterArray(String paramString1, String paramString2)
  {
    PostParameter[] arrayOfPostParameter = new PostParameter[1];
    PostParameter localPostParameter = new PostParameter(paramString1, paramString2);
    arrayOfPostParameter[0] = localPostParameter;
    return arrayOfPostParameter;
  }

  public static PostParameter[] getParameterArray(String paramString1, String paramString2, String paramString3, String paramString4)
  {
    PostParameter[] arrayOfPostParameter = new PostParameter[2];
    PostParameter localPostParameter1 = new PostParameter(paramString1, paramString2);
    arrayOfPostParameter[0] = localPostParameter1;
    PostParameter localPostParameter2 = new PostParameter(paramString3, paramString4);
    arrayOfPostParameter[1] = localPostParameter2;
    return arrayOfPostParameter;
  }

  public int compareTo(PostParameter paramPostParameter)
  {
    String str1 = this.name;
    String str2 = paramPostParameter.name;
    int i = str1.compareTo(str2);
    if (i == 0)
    {
      String str3 = this.value;
      String str4 = paramPostParameter.value;
      i = str3.compareTo(str4);
    }
    return i;
  }

  public boolean equals(Object paramObject)
  {
    int i;
    if (paramObject == null)
      i = 0;
    while (true)
    {
      return i;
      if (this == paramObject)
      {
        i = 1;
        continue;
      }
      if ((paramObject instanceof PostParameter))
      {
        PostParameter localPostParameter = (PostParameter)paramObject;
        if (this.input != null)
        {
          InputStream localInputStream1 = this.input;
          InputStream localInputStream2 = localPostParameter.input;
          if (localInputStream1.equals(localInputStream2));
        }
        else
        {
          do
          {
            i = 0;
            break;
          }
          while (localPostParameter.input != null);
        }
        String str1 = this.name;
        String str2 = localPostParameter.name;
        if (str1.equals(str2))
        {
          String str3 = this.value;
          String str4 = localPostParameter.value;
          if (str3.equals(str4))
          {
            i = 1;
            continue;
          }
        }
        i = 0;
        continue;
      }
      i = 0;
    }
  }

  public InputStream getInput()
  {
    return this.input;
  }

  public String getName()
  {
    return this.name;
  }

  public String getValue()
  {
    return this.value;
  }

  public int hashCode()
  {
    int i = this.name.hashCode() * 31;
    int j = this.value.hashCode();
    int k = (i + j) * 31;
    if (this.input != null);
    for (int m = this.input.hashCode(); ; m = 0)
      return k + m;
  }

  public boolean isFile()
  {
    if (this.input != null);
    for (int i = 1; ; i = 0)
      return i;
  }

  public String toString()
  {
    StringBuilder localStringBuilder1 = new StringBuilder("PostParameter{name='");
    String str1 = this.name;
    StringBuilder localStringBuilder2 = localStringBuilder1.append(str1).append(39).append(", value='");
    String str2 = this.value;
    StringBuilder localStringBuilder3 = localStringBuilder2.append(str2).append(39).append(", input=");
    InputStream localInputStream = this.input;
    return localInputStream + 125;
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.net2.PostParameter
 * JD-Core Version:    0.6.0
 */